package com.example.lgseckill.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.lgseckill.domain.SeckillProduct;
import com.example.lgseckill.domain.SeckillProductPreheatVO;
import com.example.lgseckill.domain.UserSeckillOrderInfoVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * Author:e
 * Date:2021/8/16 5:24 下午
 **/
public interface SeckillProductMapper extends BaseMapper<SeckillProduct> {

    @Select("" +
            "select `seckill_product_info_view`.`seckill_product_id` AS `seckill_product_id`," +
            "`seckill_product_info_view`.`product_id` AS `product_id`," +
            "`seckill_product_info_view`.`name` AS `name`," +
            "`seckill_product_info_view`.`detail` AS `detail`," +
            "`seckill_product_info_view`.`number` AS `number`," +
            "`seckill_product_info_view`.`seckill_price` AS `seckill_price`," +
            "`seckill_product_info_view`.`start_time` AS `start_time`," +
            "`seckill_product_info_view`.`end_time` AS `end_time`," +
            "`seckill_product_info_view`.`status` AS `status` " +
            "from `seckill_product_info_view` " +
            "where (" +
            "(`seckill_product_info_view`.`start_time` <= #{leNow}) " +
            "and " +
            "(`seckill_product_info_view`.`start_time` >= #{gtNow}) " +
            "and " +
            "(`seckill_product_info_view`.`status` = #{status})" +
            ")")
    List<SeckillProductPreheatVO> seckillProductPreheat(@Param("status") int status, @Param("gtNow")String gtNow, @Param("leNow")String leNow);


    void updateBatchBySecckillId(List<SeckillProduct> seckillProductList);

    List<SeckillProductPreheatVO> getSeckillList();

    List<UserSeckillOrderInfoVO> seckillOrderList();

    SeckillProductPreheatVO findOneSeckillProductByProductId(Long seckillProductId);

    void productRefresh(Long seckillId);
}
